#include<iostream>
#include<algorithm>
#include<string>

using namespace std;
int krug(string stroka);
int kvad(string stroka);
int figr(string stroka);
int strl(string stroka);

int main()
{
    string s;
    cout << "Print me staples." << endl;
    getline(cin, s);
    if (krug(s) != -1 && kvad(s) != -1 && figr(s) != -1 && strl(s) != -1)
    {
        cout << "True";
    }
    else
    {
        cout << "False";
    }
    return 0;
}


int krug(string stroka)
{
    string s = "";
    for (int i = 0; i < stroka.size(); ++i)
    {
        if (stroka[i] == '(')
        {
            s += stroka[i];
        }
        else if (stroka[i] == ')')
        {
            s += stroka[i];
        }
    }
    if (s == "")
    {
        return 0;
    }
    else if (s.find('(') == -1)
    {
        return -1;
    }
    else if (s.find(')') == -1)
    {
        return -1;
    }
    int n = s.find('(');
    if (n != 0)
    {
        return -1;
    }
    int k = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == '(')
        {
            ++k;
        }
        else if (s[i] == ')')
        {
            --k;
        }
    }
    bool flag;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s.find('(') > s.rfind(')'))
        {
            break;
        }
        if (s.find('(') != -1 && s.rfind(')') != -1)
        {
            s = s.erase(s.find('('), s.rfind(')') + 1);
        }
    }
    if (s == "")
    {
        flag = true;
    }
    else
    {
        flag = false;
    }
    if (k == 0 && flag == true)
    {
        return 1;
    }
    else
    {
        return -1;
    }
}


int kvad(string stroka)
{
    string s = "";
    for (int i = 0; i < stroka.size(); ++i)
    {
        if (stroka[i] == '[')
        {
            s += stroka[i];
        }
        else if (stroka[i] == ']')
        {
            s += stroka[i];
        }
    }
    if (s == "")
    {
        return 0;
    }
    else if (s.find('[') == -1)
    {
        return -1;
    }
    else if (s.find(']') == -1)
    {
        return -1;
    }
    int n = s.find('[');
    if (n != 0)
    {
        return -1;
    }
    int k = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == '[')
        {
            ++k;
        }
        else if (s[i] == ']')
        {
            --k;
        }
    }
    bool flag;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s.find('[') > s.rfind(']'))
        {
            break;
        }
        if (s.find('[') != -1 && s.rfind(']') != -1)
        {
            s = s.erase(s.find('['), s.rfind(']') + 1);
        }
    }
    if (s == "")
    {
        flag = true;
    }
    else
    {
        flag = false;
    }
    if (k == 0 && flag == true)
    {
        return 1;
    }
    else
    {
        return -1;
    }
}


int figr(string stroka)
{
    string s = "";
    for (int i = 0; i < stroka.size(); ++i)
    {
        if (stroka[i] == '{')
        {
            s += stroka[i];
        }
        else if (stroka[i] == '}')
        {
            s += stroka[i];
        }
    }
    if (s == "")
    {
        return 0;
    }
    else if (s.find('{') == -1)
    {
        return -1;
    }
    else if (s.find('}') == -1)
    {
        return -1;
    }
    int n = s.find('{');
    if (n != 0)
    {
        return -1;
    }
    int k = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == '{')
        {
            ++k;
        }
        else if (s[i] == '}')
        {
            --k;
        }
    }
    bool flag;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s.find('{') > s.rfind('}'))
        {
            break;
        }
        if (s.find('{') != -1 && s.rfind('}') != -1)
        {
            s = s.erase(s.find('{'), s.rfind('}') + 1);
        }
    }
    if (s == "")
    {
        flag = true;
    }
    else
    {
        flag = false;
    }
    if (k == 0 && flag == true)
    {
        return 1;
    }
    else
    {
        return -1;
    }
}


int strl(string stroka)
{
    string s = "";
    for (int i = 0; i < stroka.size(); ++i)
    {
        if (stroka[i] == '<')
        {
            s += stroka[i];
        }
        else if (stroka[i] == '>')
        {
            s += stroka[i];
        }
    }
    if (s == "")
    {
        return 0;
    }
    else if (s.find('<') == -1)
    {
        return -1;
    }
    else if (s.find('>') == -1)
    {
        return -1;
    }
    int n = s.find('<');
    if (n != 0)
    {
        return -1;
    }
    int k = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == '<')
        {
            ++k;
        }
        else if (s[i] == '>')
        {
            --k;
        }
    }
    bool flag;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s.find('<') > s.rfind('>'))
        {
            break;
        }
        if (s.find('<') != -1 && s.rfind('>') != -1)
        {
            s = s.erase(s.find('<'), s.rfind('>') + 1);
        }
    }
    if (s == "")
    {
        flag = true;
    }
    else
    {
        flag = false;
    }
    if (k == 0 && flag == true)
    {
        return 1;
    }
    else
    {
        return -1;
    }
}